﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet01 : MonoBehaviour {

    public float speedMove;
    public Sprite hit;


    private SpriteRenderer sr;

    private void Awake()
    {
        sr = transform.GetComponent<SpriteRenderer>();
    }

    void Update () {
        Move();
	}

    private void Move()
    {
        transform.Translate(Vector3.right * speedMove * Time.deltaTime);
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag.Contains("Zombies")){
            sr.sprite = hit;
            Invoke("Destroy", 0.1f);
            
        }
    }

    void Destroy()
    {
        GameObject.Destroy(gameObject);
    }




}
